#ifndef _OS_COMPAT_H
#define _OS_COMPAT_H

#include <linux/version.h>
#include <linux/mm_types.h>
#include <linux/range.h>
#include <linux/mm.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
/* Returns the number of bytes in this potentially compound page. */
static inline unsigned long page_size(struct page *page)
{
	return PAGE_SIZE << compound_order(page);
}
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)

static inline u64 range_len(const struct range *range)
{
	return range->end - range->start + 1;
}
#endif

int os_compat_add_cpu(unsigned int cpu);
int os_compat_remove_cpu(unsigned int cpu);
int os_compat_init(void);

#endif
